package cn.com.taurus.controller.getdata;

import cn.com.taurus.biz.AdminLogBiz;
import cn.com.taurus.biz.AdminsBiz;
import cn.com.taurus.entity.AdminLog;
import cn.com.taurus.entity.Admins;
import cn.com.taurus.util.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.text.SimpleDateFormat;
import java.util.Date;

@Controller
@RequestMapping("Resource")//必须要设置为Resource，不然cropper找不到东西就报错(BUG)
public class SkipController {
    @Autowired
    AdminsBiz adminsBiz;

    /**
     * 转跳到个人设置界面
     * @return
     */
    @RequestMapping("index")
    public ModelAndView index(String aAccount){
        Admins admins = adminsBiz.selectAdmisByAAccount(aAccount);
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("adminsData",admins);
        modelAndView.setViewName("major/index");
        return modelAndView;
    }

    @RequestMapping("uploadImgUrl")
    @Log(operation = "修改后台人员头像",type = 2)
    public ModelAndView uploadImgUrl(String imgUrl,String aAccount){
        ModelAndView modelAndView = new ModelAndView();
        //修改头像
        adminsBiz.updateAImgUrl(imgUrl,aAccount);
        modelAndView.setViewName("supermanager/BackgroundHomepage");
        System.out.println(adminsBiz.selectAdmisByAAccount(aAccount).toString());
        modelAndView.addObject("adminsData",adminsBiz.selectAdmisByAAccount(aAccount));
        return modelAndView;
    }

}
